package com.netease.nie.controllers;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.netease.nie.base.controllers.BaseController;
import com.netease.nie.base.exceptions.BusinessException;
import com.netease.nie.base.protocol.SystemResponseCode;
import com.netease.nie.dto.ExchangeGoodsDetailDto;
import com.netease.nie.facade.ExchangeGoodsFacade;

@RestController
@RequestMapping("/api/exchangeGoods")
public class ExchangeGoodsController extends BaseController {
	
	@Autowired
	private ExchangeGoodsFacade exchangeGoodsFacade;
	
	/**
	 * 商品详情接口
	 * @param id
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/detail", method = RequestMethod.GET, produces = "application/json")
	public String detail(Integer id) throws Exception {
		if (id == null)
			throw new BusinessException(SystemResponseCode.PARAM_KEY_ILLEGAL.getCode(), "商品id不合法");
		ExchangeGoodsDetailDto exchangeGoodsDetailDto = exchangeGoodsFacade.queryGoodsDetailDtoById(id);
		return jsonSuccess(exchangeGoodsDetailDto);
	}
	
}
